
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast'
const app = getApp()
Component({
  options: {
    styleIsolation: 'isolated'
  },
  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array,
      value: []
    },
    
  },

  /**
   * 组件的初始数据
   */
  data: {
    tabbarlist:[
      {
        name:'距离最近',
        selected:true,
        module:'youthclub',
        action:'recently',
      },
      {
        name:'最受欢迎',
        selected:false,
        module:'youthclub',
        action:'welcome',
      },
      {
        name:'评价最高',
        selected:false,
        module:'youthclub',
        action:'bestpick',
      },
      {
        name:'线上组织',
        selected:false,
        module:'youthclub',
        action:'online',
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onTapChild(e){
      let ind = e.currentTarget.dataset.id;
      this.data.tabbarlist.forEach((item,index) => {
        index == ind ? item.selected = true :item.selected = false;
      })
      this.setData({
        tabbarlist:this.data.tabbarlist
      })

      // detail对象，提供给事件监听函数
      var myEventDetail = {
        module: e.currentTarget.dataset.module,
        action: e.currentTarget.dataset.action
      } 
      // 触发事件的选项
      var myEventOption = {} 
      // 使用 triggerEvent 方法触发自定义组件事件，指定事件名、detail对象和事件选项
      this.triggerEvent('parentEvent', myEventDetail, myEventOption)

    }

    
  }
})